<html>
<head><meta charset="utf-8"><title>new pass manager · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html">new pass manager</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="175360041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/175360041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#175360041">(Sep 10 2019 at 17:35)</a>:</h4>
<p>Is anyone already working on the new pass manager? <a href="https://github.com/rust-lang/rust/issues/64289" target="_blank" title="https://github.com/rust-lang/rust/issues/64289">https://github.com/rust-lang/rust/issues/64289</a><br>
If not, I would be interested to try this myself</p>



<a name="175381342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/175381342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#175381342">(Sep 10 2019 at 21:47)</a>:</h4>
<p>Nope, not aware of anyone working on newpm yet. Feel free :)</p>



<a name="177193003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/177193003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#177193003">(Oct 02 2019 at 21:12)</a>:</h4>
<p>Did you have any luck with newpm?</p>



<a name="177263886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/177263886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#177263886">(Oct 03 2019 at 16:56)</a>:</h4>
<p>I started poking at it a little, mostly to learn how the new bits work, nothing to run yet</p>



<a name="177263917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/177263917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#177263917">(Oct 03 2019 at 16:56)</a>:</h4>
<p>unfortunately I got sidetracked with other work</p>



<a name="177520122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/177520122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#177520122">(Oct 07 2019 at 13:43)</a>:</h4>
<p>Looking forward to seeing this in action. Apparently the new pass manager can improve optimization quality: <a href="https://groups.google.com/d/msg/llvm-dev/CZmUJC4gMjQ/004NTMEYBAAJ" target="_blank" title="https://groups.google.com/d/msg/llvm-dev/CZmUJC4gMjQ/004NTMEYBAAJ">https://groups.google.com/d/msg/llvm-dev/CZmUJC4gMjQ/004NTMEYBAAJ</a></p>



<a name="179256417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/179256417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#179256417">(Oct 28 2019 at 17:48)</a>:</h4>
<p>FYI this is still on my mind, but personal life has been intense lately</p>



<a name="185099460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/185099460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#185099460">(Jan 08 2020 at 11:09)</a>:</h4>
<p>I's there any summary on how the new pass manager is different from the old one and why?<br>
I know the new pass manager was a multi-year effort, but I used only the most basic functionality in the old pass manager myself, so I find it hard to imagine why it would be such a big deal.</p>



<a name="185107709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/185107709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#185107709">(Jan 08 2020 at 13:07)</a>:</h4>
<p>I'm not really familiar either, but I believe the main difference and advantage is in how it manages analysis passes.</p>



<a name="185107827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/185107827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#185107827">(Jan 08 2020 at 13:08)</a>:</h4>
<p>I believe those get computed more lazily now and also get invalidated more lazily (e.g. if a transform pass doesn't make any changes, even if it does not explicitly preserve some specific analysis.)</p>



<a name="185107894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/185107894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#185107894">(Jan 08 2020 at 13:09)</a>:</h4>
<p>And apparently some kinds of analysis couldn't be accessed in some types of transformation passes before ... or something.</p>



<a name="188936644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188936644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188936644">(Feb 24 2020 at 15:36)</a>:</h4>
<p>I'm working on some MIR optimizations and I'm seeing a massive regression in compile times when my optimization is enabled due to LLVM (on one particular test case). I'm working on trying to debug this more but I've noticed that if I enabled the new pass manager via <code>-Znew-llvm-pass-manager</code>, that seems to resolve the issue. </p>
<p>Is there a timeline for using the new pass manager by default or are we blocked on something? Is there anything I can do to help get that flipped on by default?</p>



<a name="188972964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188972964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> andjo403 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188972964">(Feb 24 2020 at 22:26)</a>:</h4>
<p>one reason to not make the switch is that not even clang is using the new pass manager yet</p>



<a name="188973282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188973282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188973282">(Feb 24 2020 at 22:30)</a>:</h4>
<p>Ah, I see. I was just reading in LLVM weekly that passes are still being ported to it. Perhaps "experimental pass manager" is a better term <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="188974358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188974358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188974358">(Feb 24 2020 at 22:44)</a>:</h4>
<p>what optimizations those are</p>



<a name="188974396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188974396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188974396">(Feb 24 2020 at 22:45)</a>:</h4>
<p>MIR optimisations should first and foremost be for reducing compile times, optimising a generic IR will not allow super high quality code anyway – LLVM will do it.</p>



<a name="188979088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188979088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188979088">(Feb 24 2020 at 23:54)</a>:</h4>
<p>The MIR inliner. It's a win for most of the rustc-perf benchmarks but <code>deeply-nested</code> shows an enormous slowdown when it's enabled.</p>



<a name="188979194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188979194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188979194">(Feb 24 2020 at 23:56)</a>:</h4>
<p>I think the core issue is that some of the iterator methods are currently just slightly too costly for LLVM to inline them. After turning on MIR inliner, they just squeeze by the cost threshold which triggers an exponential blowup in terms of locals.</p>



<a name="188979211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188979211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188979211">(Feb 24 2020 at 23:56)</a>:</h4>
<p>I have a number of local tweaks that I think fix that at the MIR level but I'm still seeing LLVM take massive amounts of compilation time.</p>



<a name="188979293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188979293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188979293">(Feb 24 2020 at 23:58)</a>:</h4>
<p>I've tried following the guide here <a href="https://rust-lang.github.io/rustc-guide/codegen/debugging.html" target="_blank" title="https://rust-lang.github.io/rustc-guide/codegen/debugging.html">https://rust-lang.github.io/rustc-guide/codegen/debugging.html</a> but unfortunately if I set <code>-Ccodegen-units=1</code>, the slowdown goes away and if I use <code>opt</code> on the individual files generated by <code>--emit llvm-ir</code>, there's no slowdown.</p>



<a name="188979338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188979338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188979338">(Feb 24 2020 at 23:59)</a>:</h4>
<p>So I'm not really sure where to go next. I've been starting to poke at the codegen partition code; maybe there's something that can be tweaked there? That's just speculation on my part though.</p>



<a name="188979610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188979610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188979610">(Feb 25 2020 at 00:03)</a>:</h4>
<p>I happened to notice that the new pass manager also resolves the issue but it looks like that's currently a dead end.</p>



<a name="188985516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188985516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188985516">(Feb 25 2020 at 02:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125250">Wesley Wiser</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/new.20pass.20manager/near/188979610" title="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/new.20pass.20manager/near/188979610">said</a>:</p>
<blockquote>
<p>I happened to notice that the new pass manager also resolves the issue but it looks like that's currently a dead end.</p>
</blockquote>
<p>Very likely to be because "new pass manager" is not full featured yet?</p>



<a name="188985527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/188985527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#188985527">(Feb 25 2020 at 02:05)</a>:</h4>
<p>Consider tweaking inlining thresholds in Rust?</p>



<a name="189423922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/189423922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#189423922">(Mar 01 2020 at 07:43)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> Have you tried extracting the LLVM IR for the codegen unit which slows down? Maybe you could report a performance problem upstream to LLVM?</p>



<a name="190117470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190117470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190117470">(Mar 09 2020 at 21:03)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> Sorry, just getting back to this. I do have the LLVM IR for the codegen unit which is slow. I'm not really sure how to get <code>opt</code> to do exactly what <code>rustc</code> is doing though so I don't have a clean repro. </p>
<p>I suspect a lot of this is self-inflicted and possibly not a bug in LLVM since we've slapped <code>#[inline]</code> on pretty much everything in <code>std::iter</code></p>



<a name="190117549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190117549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190117549">(Mar 09 2020 at 21:04)</a>:</h4>
<p>If anyone has advice on invoking <code>opt</code> with the same set of optimization passes <code>rustc</code> uses, that would be very helpful! :)</p>



<a name="190150808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190150808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190150808">(Mar 10 2020 at 08:32)</a>:</h4>
<p>I'm assuming you're using opt -O3 currently? You can try -Zprint-llvm-passes and pass the output of that to opt.</p>



<a name="190151019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190151019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190151019">(Mar 10 2020 at 08:36)</a>:</h4>
<p>Regarding the original question, we should give using the new pass manager another try after updating to LLVM 10. There are a couple of issues I'm still aware of, so not sure if we'll actually make the switch already.</p>



<a name="190272181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190272181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190272181">(Mar 11 2020 at 11:39)</a>:</h4>
<p>You want the IR before any LLVM passes run, I'm not sure if we have an easy way to output that.</p>



<a name="190279103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190279103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190279103">(Mar 11 2020 at 13:14)</a>:</h4>
<p>That's the <code>-Cno-prepopulate-passes</code> flag right? <a href="https://rustc-dev-guide.rust-lang.org/codegen/debugging.html#compiler-options-to-know-and-love" target="_blank" title="https://rustc-dev-guide.rust-lang.org/codegen/debugging.html#compiler-options-to-know-and-love">https://rustc-dev-guide.rust-lang.org/codegen/debugging.html#compiler-options-to-know-and-love</a></p>



<a name="190394532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190394532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190394532">(Mar 12 2020 at 14:22)</a>:</h4>
<p>In theory, not sure it's accurate in practice =P</p>



<a name="190395972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190395972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190395972">(Mar 12 2020 at 14:33)</a>:</h4>
<p>relatively accurate. AFAIR we still just output an error if we would run any passes</p>



<a name="190400545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190400545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190400545">(Mar 12 2020 at 15:09)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> Do we have a limit for how large functions can be before we stop inlining?</p>



<a name="190401599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190401599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190401599">(Mar 12 2020 at 15:17)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> not currently no</p>



<a name="190404672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190404672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190404672">(Mar 12 2020 at 15:41)</a>:</h4>
<p>Let me brain dump what I've learned so far in case it helps spark an idea from anyone else:</p>
<p>The problematic test case is <a href="https://github.com/rust-lang/rustc-perf/blob/master/collector/benchmarks/deeply-nested/src/lib.rs" target="_blank" title="https://github.com/rust-lang/rustc-perf/blob/master/collector/benchmarks/deeply-nested/src/lib.rs"><code>deeply-nested</code></a>.</p>
<p>With MIR inlining enabled, we hand LLVM a couple thousand lines of IR for <code>foo()</code> which it chews through very quickly (this isn't the compilation time issue). The problem is that because we box the value as <code>Box&lt;dyn Iterator&lt;Item = ()&gt;&gt;</code> , the collector also has to codegen <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/monomorphize/collector.rs#L504-L536" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/monomorphize/collector.rs#L504-L536">all of the trait methods</a>. It's this code which LLVM is choking on because it spends a huge amount of processing the <code>Iterator::next()</code> body after inlining all of the <code>Chain</code> adapters. </p>
<p>I suspect the reason that LLVM inlining is triggering so aggressively here is that currently something in <code>std::iter</code> is just over the threshold to inline and so it is not currently getting inlined but with MIR inlining enabled, it may now be just small enough to inline. I have not confirmed this though.</p>



<a name="190409256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/new%20pass%20manager/near/190409256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/new.20pass.20manager.html#190409256">(Mar 12 2020 at 16:14)</a>:</h4>
<p>You could try adding a max function size and stop inlining into such functions. It might help with the regression since you don't seem too sure about that cause.</p>
<p>We could also just regress <code>deeply-nested</code> since it's just a synthetic benchmark. It would be interesting to see if adding or removing more <code>.chain(empty())</code>s from it changes the regression.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>